package belajarzk.database.model;

// Generated Oct 23, 2009 4:59:38 PM by Hibernate Tools 3.2.4.CR1

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * Tbmrole generated by hbm2java
 */
@Entity
@Table(name = "tbmrole")
public class Tbmrole implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -4566297457209734092L;
	private String roleId;
	private String roleName;

	private Set<Menu> menus = new HashSet<Menu>();

	@ManyToMany(targetEntity = Menu.class, cascade = {
			CascadeType.MERGE, CascadeType.REMOVE, CascadeType.PERSIST })
	@OrderBy(value = "root asc, child asc")
	@JoinTable(name = "job_has_menu", joinColumns = @JoinColumn(name = "job"), inverseJoinColumns = @JoinColumn(name = "menu"))
	public Set<Menu> getMenus() {
		return menus;
	}

	public void setMenus(Set<Menu> menus) {
		this.menus = menus;
	}

	public Tbmrole() {
	}

	public Tbmrole(String roleId, String roleName) {
		this.roleId = roleId;
		this.roleName = roleName;
	}

	@Id
	@Column(name = "roleid", unique = true, nullable = false, length = 6)
	public String getRoleId() {
		return this.roleId;
	}

	public void setRoleId(String roleId) {
		this.roleId = roleId;
	}

	@Column(name = "rolename", nullable = true, length = 50)
	public String getRoleName() {
		return this.roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

}
